package webcrawler;

import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Date;

public class test {

	public static void main(String args[]) throws Exception {
		int c;
		URL hp = new URL("http://www.java-samples.com/j2me/");
		URLConnection hpCon = hp.openConnection();
		System.out.println("Date: " + new Date(hpCon.getDate()));
		System.out.println("Content-Type: " + hpCon.getContentType());
		System.out.println("Expires: " + hpCon.getExpiration());
		System.out.println("Last-Modified: "
				+ new Date(hpCon.getLastModified()));
		int len = hpCon.getContentLength();
		System.out.println("Content-Length: " + len);
		// if (len > 0) {
		System.out.println("=== Content ===" + hpCon.getContent());
		InputStream input = hpCon.getInputStream();
		int i = len;

		String type = hpCon.guessContentTypeFromStream(input);
		while (((c = input.read()) != -1) && (i > 0)) {
			System.out.print((char) c);
		}
		input.close();
		// } else {
		System.out.println("No Content Available");
		// }
	}
}
